<div id="main">
    <div id="contents">
        <form method="post" action="#" name="filters">
            <fieldset>
                <legend>
                    <label sid="content.filter_webs_content_filter"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label>
                                    <label sid="content.filter_webs_content_filter_filter"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input type="checkbox" value="0" name="id2342">
                                Proxy
                                <input type="checkbox" value="0" name="id2343">
                                Java
                                <input type="checkbox" value="0" name="id2344">
                                ActiveX
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input class="button" type="button" name="submit" sid="sbutton.save">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="content.filter_webs_URL_filter_title"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="addURLFilter">
                                    <label sid="content.filter_webs_url_fitler_url"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="url" type="text" maxlength="32" size="16" name="url">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input id="save_button_1" class="button" type="button" onclick="virtual_add_1();" name="save_button_1" sid="sbutton.add">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="content.filter_webs_url_filter_current"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table id="urltable" class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%"> </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="content.filter_webs_host_fitler_title"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="addHostFilter">
                                    <label sid="content.filter_webs_host_fitler_host"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="hostname" type="text" maxlength="32" size="16" name="hostname">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input id="save_button_2" class="button" type="button" onclick="virtual_add_2();" name="save_button_2" sid="sbutton.add">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="content.filter_webs_host_fitler_current"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table id="hostname_table" class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%"> </table>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<br>
<div id="helpContainer">
    <div id="help">
        <div>
            <h2>
                <label sid="share.help"></label>
            </h2>
        </div>
        <div id="helpBody">
        <dl>
            <dt class="term">
                <label sid="content.filter_title"></label>
            </dt>
            <dd class="definition">
                <label sid="content.filter_webs_content_filter_note"></label>
            </dd>
            <dt class="term">
                <label sid="content.filter_webs_URL_filter_title"></label>
            </dt>
            <dd class="definition">
                <label sid="content.filter_webs_URL_filter_title_note"></label>
            </dd>
            <dt class="term">
                <label sid="content.filter_webs_host_fitler_title"></label>
            </dt>
            <dd class="definition">
                <label sid="content.filter_webs_host_fitler_title_note"></label>
            </dd>
        </dl>
    </div>
    </div>
</div>


<script type="text/javascript" src="js/libTable.js"></script>
<script type="text/javascript">
    if(typeof(content.filter_webs_content_filter_note)=="undefined"){
       $("#contents").attr("id","contents_stat");
       $("#helpContainer").hide();
    }
var virtual_data_1 = new Array();
var virtual_data_2 = new Array();
var old_virtual_1=0;
var old_virtual_2=0;
load_html();
    $("[name=submit]").click(function () {
		$(".errormsg").html('');
		var settext='&id2342='+gettruevalue("id2342",$("[name=id2342]").val())+'&id2343='+gettruevalue("id2343",$("[name=id2343]").val())+'&id2344='+gettruevalue("id2344",$("[name=id2344]").val());
		submitform(modules["set_data"],settext,"content_filtering_main_load");
	});
	
function load_html(){
	var sendtext = '&id=2342&id=2343&id=2344&id=2340&id=2341';
	DataRequest("get_json",sendtext,function(data){
		updatecfgvalue("id2342",data["id2342"]);
		updatecfgvalue("id2343",data["id2343"]);
		updatecfgvalue("id2344",data["id2344"]);
		if(data["id2340"].indexOf(";")>=0){
		var tmparray_1 = data["id2340"].split(";");
		}else{
		var tmparray_1 = new Array();
		tmparray_1[0] = data["id2340"];
		}
		if(data["id2341"].indexOf(";")>=0){
			var tmparray_2 = data["id2341"].split(";");
		}else{
			var tmparray_2 = new Array();
			tmparray_2[0] = data["id2341"];
		}
		//if(tmparray_1[0]!==""){
			virtual_data_1 = tmparray_1;
			virtual_paint_list_1(tmparray_1);
		//}
		//if(tmparray_2[0]!==""){
			virtual_data_2 = tmparray_2;
			virtual_paint_list_2(tmparray_2);
		//}
	});
}

function virtual_paint_list_1(data){
 var data_new=new Array();
 var j=0;
  for(var i=0;i<data.length;i++){
  	if(data[i]!==""&&data[i]){
 	var ID = parseInt(parseInt(i)+1);
  	var url = data[i];
  data_new.push({ID:ID,url:url});
  j = i;
}
 }
 var fun_arr = [{type:"modify",name:"virtual_change_1"},{type:"del",name:"virtual_del_1"}];
 var tab = new libTable(new Array(content.filter_webs_url_fitler_No,content.filter_webs_url_fitler_url,msg.op),data_new,1,10);
 print_table("urltable",tab,fun_arr, true);
}

function virtual_paint_list_2(data){
 var data_new=new Array();
 var j=0;
  for(var i=0;i<data.length;i++){
  		if(data[i]!==""&&data[i]){
 	var ID = parseInt(parseInt(i)+1);
  	var hostname = data[i];
  data_new.push({ID:ID,hostname:hostname});
  j = i;
}
 }
 var fun_arr = [{type:"modify",name:"virtual_change_2"},{type:"del",name:"virtual_del_2"}];
 var tab = new libTable(new Array(content.filter_webs_url_fitler_No,content.filter_webs_host_fitler_host,msg.op),data_new,1,10);
 print_table("hostname_table",tab,fun_arr, true);
}

function virtual_change_1(id,url)
{
 obj = virtual_data_1[parseInt(id)-1];
 old_virtual_1 = parseInt(id)-1;
 with(obj){
  $("#url").val(url);
 }
 $("#save_button_1").val(sbutton.modify);
}

function virtual_change_2(id,hostname)
{
 obj = virtual_data_2[parseInt(id)-1];
 old_virtual_2 = parseInt(id)-1;
 with(obj){
  $("#hostname").val(hostname);
 }
 $("#save_button_2").val(sbutton.modify);
}


function virtual_add_1(){
  var url = $("#url").val();
  if($("#save_button_1").val()==sbutton.modify){
  	virtual_data_1[old_virtual_1] = url;
  }else{
  	virtual_data_1[virtual_data_1.length]=url;
  }
  var resultStr = '';
  for(var i=0;i<virtual_data_1.length;i++){
  	resultStr += virtual_data_1[i]+";";
  	}
  	resultStr = resultStr.substr(0,resultStr.length-1);
  var settext='&id2340='+resultStr;
  submitform(modules["set_data"],settext,"content_filtering_main_load");
  load_html();
}

function virtual_add_2(){
  var hostname = $("#hostname").val();
  if($("#save_button_2").val()==sbutton.modify){
  	virtual_data_2[old_virtual_2] = hostname;
  }else{
  	virtual_data_2[virtual_data_2.length]=hostname;
  }
  var resultStr = '';
  for(var i=0;i<virtual_data_2.length;i++){
  	resultStr += virtual_data_2[i]+";";
  	}
  	resultStr = resultStr.substr(0,resultStr.length-1);
  var settext='&id2341='+resultStr;
  submitform(modules["set_data"],settext,"content_filtering_main_load");
  load_html();
}

function virtual_del_1(id,url){
 if(confirm(msg.confirm_del)){
// show_message("del",msg.deleting);
 virtual_data_1[parseInt(id)-1] = [];
 var resultStr = '';
  for(var i=0;i<virtual_data_1.length;i++){
  	if(virtual_data_1[i]&&virtual_data_1[i]!=""){
  		resultStr += virtual_data_1[i]+";";
 	 }
  	}
  	resultStr = resultStr.substr(0,resultStr.length-1);
  var settext='&id2340='+resultStr;
  submitform(modules["set_data"],settext,"content_filtering_main_load");
  load_html();
 }
}

function virtual_del_2(id,hostname){
 if(confirm(msg.confirm_del)){
// show_message("del",msg.deleting);
 virtual_data_2[parseInt(id)-1] = [];
var resultStr = '';
  for(var i=0;i<virtual_data_2.length;i++){
  	if(virtual_data_2[i]&&virtual_data_2[i]!=""){
  	resultStr += virtual_data_2[i]+";";
  }
  	}
  	resultStr = resultStr.substr(0,resultStr.length-1);
  var settext='&id2341='+resultStr;
  submitform(modules["set_data"],settext,"content_filtering_main_load");
  load_html();
 }
}
</script>
